package com.custom.util

import android.util.Log.e
import com.alibaba.fastjson.JSON

const val isShow: Boolean = true

fun LogStr(tag: Any, any_: Any?) {
    if (isShow) {
        e("$tag----->", any_?.toString())
    }
}

fun LogStr(any_: Any?) {
    if (isShow) {
        e("obj----->", any_?.toString())
    }
}

fun LogObj(obj: Any?) {
    if (isShow) {
        e("str----->", JSON.toJSONString(obj))
    }
}

fun LogObj(tag: Any, obj: Any?) {
    if (isShow) {
        e("$tag----->", JSON.toJSONString(obj))
    }
}

fun LogStrL(tag: Any?, str: Any?) {
    println("   ")
    println("   ")
    e(tag.toString(), "   ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓")
    val str_ = str.toString()
    var now_ = 0
    var line = 0
    if (str_.length > 4000) {
        while (now_ < str_.length) {
            if (now_ + 4000 < str_.length) {
                e("$line ：", str_.substring(now_, now_ + 4000))
            } else {
                e("$line ：", str_.substring(now_, str_.length))
            }
            line += 1
            now_ += 4000
        }
    } else {
        e("$line ：", str_)
    }
    e(tag.toString(), "   ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑")
}

fun LogObjL(tag: Any?, obj: Any?) {
    println("   ")
    println("   ")
    e(tag.toString(), "   ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓")
    val str_ = JSON.toJSONString(obj)
    var now_ = 0
    var line = 0
    if (str_.length > 4000) {
        while (now_ < str_.length) {
            if (now_ + 4000 < str_.length) {
                e("$line ：", str_.substring(now_, now_ + 4000))
            } else {
                e("$line ：", str_.substring(now_, str_.length))
            }
            line += 1
            now_ += 4000
        }
    } else {
        e("$line ：", str_)
    }
    e(tag.toString(), "   ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑")
}

